<?php

namespace  app\service;


use app\model\PartnerLogModel;
use app\model\PartnerUserModel;
use app\model\WarehouseModel;
use app\model\WmsCustomerModel;
use app\model\WmsProviderModel;
use think\facade\Db;

Class WmsProviderService{
    public static  function info()
    {

        $warehouseType=WarehouseModel::GetAllWarehouseType();
        $bussineType=WarehouseModel::GetAllBussineType();
        return [
            'warehouseType'=>$warehouseType,
            'bussineType'=>$bussineType
        ];
    }

    public  static  function  lists($param){
         return  WmsProviderModel::list($param);
    }

    public  static  function  line_data($param){
        return  WmsProviderModel::line_data($param);
    }

    public  static  function  add($data,$logParam)
    {


        Db::startTrans();
       $res= WmsProviderModel::add($data);
        $dataLog=[
            'partner_user_id'=>$logParam['uid'],
            'log_type'=>2,
            'request_ip'=>$logParam['ip'],
            'add_time'=>getNowDateTime(),
            'log_desc'=>'添加仓库',
            'status'=>1,
            'partner_id'=>$data['partner_id']
        ];
        
        if ($res){
            Db::commit();
            return 10000;
        }else{
            // 回滚事务
            Db::rollback();
            return 10003;
        }
    }
    public  static  function  edit($data,$logParam,$id)
    {


        Db::startTrans();
        $data['update_time']=getNowDateTime();
         $res= WmsProviderModel::edit($data,$id);
        $dataLog=[
            'partner_user_id'=>$logParam['uid'],
            'log_type'=>2,
            'request_ip'=>$logParam['ip'],
            'add_time'=>getNowDateTime(),
            'log_desc'=>'修改客户信息',
            'status'=>1,
            'partner_id'=>$data['partner_id']
        ];
        
          if ($res){
            Db::commit();
            return 10000;
        }else{
            // 回滚事务
            Db::rollback();

            return 10003;
        }
    }
    public  static  function  del($data,$logParam,$id)
    {


        Db::startTrans();
        $res= WmsProviderModel::del($id);
        $dataLog=[
            'partner_user_id'=>$logParam['uid'],
            'log_type'=>2,
            'request_ip'=>$logParam['ip'],
            'add_time'=>getNowDateTime(),
            'log_desc'=>'删除客户信息',
            'status'=>1,
            'partner_id'=>$data['partner_id']
        ];
        
        if ($res){
            Db::commit();
            return 10000;
        }else{
            // 回滚事务
            Db::rollback();
            return 10003;
        }
    }
}